﻿using System;
using System.Globalization;
using System.Web.UI;

namespace BookingEngine.Web.en
{
    public partial class Reservation : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var hotelCode = Request["HotelID"];
            var roomCode = Request["RoomCode"];
            var rateCode = Request["RateCode"];
            var checkInDate = Request["ChkIN"];
            var checkOutDate = Request["ChkOUT"];
            var roomsNumber = Request["Rooms"];
            var adultsNumber = Request["Adult"];
            var childrenNumber = Request["Child"];

            Session["Reservation_HotelCode"] = string.IsNullOrEmpty(hotelCode) ? string.Empty : hotelCode.Trim();
            Session["Reservation_RoomCode"] = string.IsNullOrEmpty(roomCode) ? string.Empty : roomCode.Trim();
            Session["Reservation_RateCode"] = string.IsNullOrEmpty(rateCode) ? string.Empty : rateCode.Trim();
            Session["Reservation_CheckInDate"] = (string.IsNullOrEmpty(checkInDate) ? DateTime.Now.Date.AddDays(1) : DateTime.Parse(checkInDate)).ToString("yyyy-MM-dd");
            Session["Reservation_CheckOutDate"] = (string.IsNullOrEmpty(checkOutDate) ? DateTime.Now.Date.AddDays(2) : DateTime.Parse(checkOutDate)).ToString("yyyy-MM-dd");
            Session["Reservation_RoomsNumber"] = (string.IsNullOrEmpty(roomsNumber) ? 1 : int.Parse(roomsNumber)).ToString(CultureInfo.InvariantCulture);
            Session["Reservation_AdultsNumber"] = (string.IsNullOrEmpty(adultsNumber) ? 1 : int.Parse(adultsNumber)).ToString(CultureInfo.InvariantCulture);
            Session["Reservation_ChildrenNumber"] = (string.IsNullOrEmpty(childrenNumber) ? 0 : int.Parse(childrenNumber)).ToString(CultureInfo.InvariantCulture);
            Session["Reservation_Culture"] = "en-US";

            formBox.Arguments["HotelCode"] = string.IsNullOrEmpty(hotelCode) ? string.Empty : hotelCode.Trim();
            formBox.Arguments["RoomCode"] = string.IsNullOrEmpty(roomCode) ? string.Empty : roomCode.Trim();
            formBox.Arguments["RateCode"] = string.IsNullOrEmpty(rateCode) ? string.Empty : rateCode.Trim();
            formBox.Arguments["CheckInDate"] = (string.IsNullOrEmpty(checkInDate) ? DateTime.Now.Date.AddDays(1) : DateTime.Parse(checkInDate)).ToString("yyyy-MM-dd");
            formBox.Arguments["CheckOutDate"] = (string.IsNullOrEmpty(checkOutDate) ? DateTime.Now.Date.AddDays(2) : DateTime.Parse(checkOutDate)).ToString("yyyy-MM-dd");
            formBox.Arguments["RoomsNumber"] = (string.IsNullOrEmpty(roomsNumber) ? 1 : int.Parse(roomsNumber)).ToString(CultureInfo.InvariantCulture);
            formBox.Arguments["AdultsNumber"] = (string.IsNullOrEmpty(adultsNumber) ? 1 : int.Parse(adultsNumber)).ToString(CultureInfo.InvariantCulture);
            formBox.Arguments["ChildrenNumber"] = (string.IsNullOrEmpty(childrenNumber) ? 0 : int.Parse(childrenNumber)).ToString(CultureInfo.InvariantCulture);
            formBox.Arguments["Culture"] = "en-US";
        }
    }
}